import { createRouter, createWebHashHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import OrganIzation from '../views/OrganIzation.vue'
import NewsInformation from '../views/NewsInformation.vue'
import BusinessDynamics from '../views/BusinessDynamics.vue'
import InformationDisclosure from '../views/InformationDisclosure.vue'
import PartyConstruction from '../views/PartyConstruction.vue'
import EXCHANGE from '../views/EXCHANGE.vue'
import SupervisionSuggestions from '../views/SupervisionSuggestions.vue'
import IParticipate from '../views/IParticipate.vue'
import BenevolentStyle from '../views/BenevolentStyle.vue'
import ShowPhotos from '../views/ShowPhotos.vue'
import DetialInformation from '../components/DetialInformation.vue'
import NULL from '../components/NULL.vue'
import RememberingDeceased from '../views/RememberingDeceased.vue'
import SearchList from '../views/SearchList.vue'

const routes = [
  {
    path: '/',
    name: '首页',
    meta: {
      name: "首页"
    },
    component: HomeView,
  },
  {
    path: '/OrganIzation',
    name: '组织机构',
    meta: {
      name: "组织机构"
    },
    component: OrganIzation,
  },
  {
    path: '/NewsInformation',
    name: '新闻动态',
    meta: {
      name: "新闻动态"
    },
    component: NewsInformation,
  },
  {
    path: '/BusinessDynamics',
    name: '业务动态',
    meta: {
      name: "业务动态"
    },
    component: BusinessDynamics,
  },
  {
    path: '/InformationDisclosure',
    name: '信息公开',
    meta: {
      name: "信息公开"
    },
    component: InformationDisclosure,
  },
  {
    path: '/PartyConstruction',
    name: '党建工作',
    meta: {
      name: "党建工作"
    },
    component: PartyConstruction,
  },
  {
    path: '/EXCHANGE',
    name: '对外交流',
    meta: {
      name: "对外交流"
    },
    component: EXCHANGE,
  },
  {
    path: '/SupervisionSuggestions',
    name: '监督建议',
    meta: {
      name: "监督建议"
    },
    component: SupervisionSuggestions,
  },
  {
    path: '/IParticipate',
    name: '我要参与',
    meta: {
      name: "我要参与"
    },
    component: IParticipate,
  },
  {
    path: '/BenevolentStyle',
    name: '博爱风采',
    meta: {
      name: "博爱风采"
    },
    component: BenevolentStyle,
  },
  {
    path: '/RememberingDeceased',
    name: '逝者缅怀',
    meta: {
      name: "逝者缅怀"
    },
    component: RememberingDeceased,
  },
  {
    path: '/DetialInformation',
    name: 'DetialInformation',
    meta: {
      name: "详情页面",
      isShow: false,
    },
    component: DetialInformation,
  },
  {
    path: '/SearchList',
    name: 'SearchList',
    meta: {
      name: "搜索列表",
      isShow: false,
    },
    component: SearchList,
  },
  {
    path: '/ShowPhotos',
    name: '图片展示',
    meta: {
      name: "图片展示",
      isShow: false,
    },
    component: ShowPhotos,
  },
  {
    path: '/NULL',
    name: 'NULL',
    meta: {
      name: "NULL",
      isShow: false,
      isNull: false,
    },
    component: NULL,
  },

]
const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes
})
router.beforeEach((to, from, next) => {
  const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
  if (isMobile) {
    if (to.query && to.query.id) {
      window.location.href = `http://192.168.0.202:8089/#/pages/other/newsDetail?id=${to.query.id}&isEnter=true`
    } else {
      window.location.href = 'http://192.168.0.202:8089/#/pages/menu/organization?isEnter=true'
    }
  } else {
    next()
  }
})
export default router
